// component/todoitem/todoitem.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    // options: Array,
    // operateWidth: Number,
    // visible: Boolean,
    // toggle: Boolean,
    // actions: Array,
    todo: Object,
    index: Number,
    entry: String,
    toggle:Boolean,
  },

  /**
   * 组件的初始数据
   */
  data: {
    options: [
      //"delete_fill", "like_fill", "share_fill","success_fill"
    ],
    operateWidth: 0,
    // visible: false,
    
    
    optioncolor: "#ffffff",
  },

  /**
   * 生命周期函数,可以为函数，或一个在methods段中定义的方法名
   */
  lifetimes: {
    attached: function() {
      if (this.properties.entry == "homepage") {
        this.setData({
          options: [
            "success_fill"
          ],
          optioncolor: "#ffffff",
        })
      } else if (this.properties.entry == "history") {
        this.setData({
          options: [
            "delete_fill"
          ],
          optioncolor: "#ff0000",
        })
      }
      this.setData({
        operateWidth: this.data.options.length * 60
      })
      // console.log(this.data.options.length)
      // console.log("component already")
      // console.log(this.data)
      // console.log(this.properties)
    },
    moved: function() {},
    detached: function() {},
  },

// observers:{
//   '':function(){

//   }
// },
  /**
   * 组件的方法列表
   */
  methods: {
    actionsTap: function(e) {
      // console.log("actionsTap")
      // console.log(e)
      var id = e.currentTarget.dataset.id
      this.setData({
        visible: true
      });
      var type = "actionsTap"
      this.triggerEvent('tap', {
        type,
        id
      }, {})
    },
    detail: function(e) {
      // console.log("detail")
      // console.log(e)
      var id = e.currentTarget.dataset.id
      var type = "detail"
      this.triggerEvent('tap', {
        type,
        id
      }, {})
      // wx.setStorageSync("currentId", e.currentTarget.dataset.id)
      // wx.switchTab({
      //   url: '../add/add',
      // })
    },
  }
})